# The C and C++ rules are already setup by default.
# The only one that needs changing is the assembler 
# rule, as we use nasm instead of GNU as.

SOURCES=src/loader.o src/process.o src/main.o src/common.o src/descriptor_tables.o src/gdt.o src/interrupt.o src/isr.o src/kheap.o src/monitor.o src/ordered_array.o src/paging.o src/syscall.o src/task.o src/timer.o

BINARYS=cst/keybrd.o

CSTSOURCES=cst/8259.o cst/keybrdc.o cst/mouse.o

CFLAGS=-nostdlib -nostdinc -fno-builtin -I./include -I./cst -I./src
CXXFLAGS=-I./include -I./cst -I./src
LDFLAGS=-Tlinker.ld
ASFLAGS=-felf

all: $(SOURCES) $(BINARYS) $(CSTSOURCES) link

clean:
	-rm src/*.o kernel cst/*.o

link:
	ld $(LDFLAGS) -o kernel -b elf32-i386 $(SOURCES) $(CSTSOURCES) -b binary $(BINARYS) --oformat elf32-i386

.s.o:
	nasm $(ASFLAGS) $<

cst/keybrd.o: ./cst/keybrd.b
	nasm -f bin -o cst/keybrd.o cst/keybrd.b

cst/cpuid.o: ./cst/cpuid.b
	nasm -f bin -o cst/cpuid.o cst/cpuid.b

